/*    */ package com.qmsk.business.manage.duty.controller;
/*    */ 
/*    */ import com.qmsk.business.manage.duty.dao.DutyDAO;
/*    */ import com.utils.gson.in.GsonHeadOneRow;
/*    */ import com.utils.gson.out.GsonEbRst;
/*    */ import com.utils.jdbc.connection.DbConnection;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.transaction.annotation.Transactional;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/duty"})
/*    */ public class DutyController
/*    */ {
/* 27 */   private static final Logger logger = Logger.getLogger(DutyController.class);
/*    */ 
/*    */   @Autowired
/*    */   private DutyDAO dao;
/*    */ 
/*    */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getListOfShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer nShopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*    */   {
/* 38 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*    */     try {
/* 40 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(nShopId, nPageIdx, 
/* 41 */         nPageSize);
/* 42 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 44 */       logger.error(e);
/* 45 */       ResponseUtils.setErrorMsgResponse(
/* 46 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void insert(HttpServletRequest request, HttpServletResponse response) {
/* 53 */     String sGsonIn = RequestUtils.getString(request, "data");
/*    */     try {
/* 55 */       int nUpdates = this.dao.insertJsonOneRow(sGsonIn);
/* 56 */       DbConnection.commit();
/* 57 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 58 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 59 */         response);
/*    */     } catch (SQLException e) {
/* 61 */       DbConnection.rollback();
/* 62 */       logger.error(e);
/* 63 */       ResponseUtils.setErrorMsgResponse(
/* 64 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 65 */         e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void update(HttpServletRequest request, HttpServletResponse response) {
/* 72 */     Integer id = RequestUtils.getInt(request, "id");
/*    */     try {
/* 74 */       String sGsonInData = request.getParameter("data");
/* 75 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 76 */       if (g == null) {
/* 77 */         ResponseUtils.setErrorMsgResponse(
/* 78 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 79 */           response);
/*    */       } else {
/* 81 */         int nResult = this.dao.updateJsonOneRow(g, id);
/* 82 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 83 */           RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 84 */           response);
/*    */       }
/* 86 */       DbConnection.commit();
/*    */     } catch (Exception e) {
/* 88 */       DbConnection.rollback();
/* 89 */       logger.error(e);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void delete(HttpServletRequest request, HttpServletResponse response) {
/* 96 */     Object[] ids = RequestUtils.getSplit(request, "id");
/*    */     try {
/* 98 */       int nUpdates = this.dao.deleteParams(ids);
/* 99 */       DbConnection.commit();
/* 100 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 101 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 102 */         response);
/*    */     } catch (SQLException e) {
/* 104 */       DbConnection.rollback();
/* 105 */       logger.error(e);
/* 106 */       ResponseUtils.setErrorMsgResponse(
/* 107 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 108 */         e.getMessage(), response);
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.manage.duty.controller.DutyController
 * JD-Core Version:    0.5.3
 */